package hm.weibo;

import android.app.FragmentManager;
import android.app.FragmentTransaction;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.ListView;

public class MainActivity extends AppCompatActivity implements View.OnClickListener {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        Button button1 = (Button) findViewById(R.id.button1);
        Button button2 = (Button) findViewById(R.id.button2);
        Button button3 = (Button) findViewById(R.id.button3);
        Button button4 = (Button) findViewById(R.id.button4);
        button1.setOnClickListener(this);
        button2.setOnClickListener(this);
        button3.setOnClickListener(this);
        button4.setOnClickListener(this);
    }


    @Override
    public void onClick(View v) {
        switch (v.getId()) {////////////botton action
            case R.id.button1:
                Check check = new Check();
                FragmentManager fragmentManager1 = getFragmentManager();
                FragmentTransaction transaction1 = fragmentManager1.
                        beginTransaction();
                transaction1.replace(R.id.main_layout, check);
                transaction1.commit();
                break;
            case R.id.button2:
                Send send = new Send();
                FragmentManager fragmentManager2 = getFragmentManager();
                FragmentTransaction transaction2 = fragmentManager2.
                        beginTransaction();
                transaction2.replace(R.id.main_layout, send);
                transaction2.commit();
                break;
            case R.id.button3:
                Search search = new Search();
                FragmentManager fragmentManager3 = getFragmentManager();
                FragmentTransaction transaction3 = fragmentManager3.
                        beginTransaction();
                transaction3.replace(R.id.main_layout, search);
                transaction3.commit();
                break;
            case R.id.button4:
                Me me = new Me();
                FragmentManager fragmentManager4 = getFragmentManager();
                FragmentTransaction transaction4 = fragmentManager4.
                        beginTransaction();
                transaction4.replace(R.id.main_layout, me);
                transaction4.commit();
                break;
            default:
                break;
        }

    }
}
